Improve AtkAction implementations
authorMatthias Clasen <mclasen@redhat.com>
Mon, 4 Feb 2013 05:53:48 +0000 (00:53 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 4 Feb 2013 05:57:46 +0000 (00:57 -0500)
Implement get_localized_name, and also translate the strings
returned by get_description.
https://bugzilla.gnome.org/show_bug.cgi?id=525226

gtk/a11y/gtkbooleancellaccessible.c
gtk/a11y/gtkbuttonaccessible.c
gtk/a11y/gtkcellaccessible.c
gtk/a11y/gtkcolorswatchaccessible.c
gtk/a11y/gtkcomboboxaccessible.c
gtk/a11y/gtkentryaccessible.c
gtk/a11y/gtkexpanderaccessible.c
gtk/a11y/gtkmenuitemaccessible.c
gtk/a11y/gtkscalebuttonaccessible.c
gtk/a11y/gtkswitchaccessible.c

index a649bd5135066ce53e26bbdbf02e6a95a16b046c..f114261901a8646e786fa5193056cba299b66399 100644 (file)
@@ -18,6 +18,7 @@
 #include "config.h"
 
 #include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
 #include "gtkbooleancellaccessible.h"
 
 struct _GtkBooleanCellAccessiblePrivate
@@ -39,7 +40,7 @@ gtk_boolean_cell_accessible_get_description (AtkAction *action,
                                              gint       i)
 {
   if (i == 0)
-    return "toggles the cell";
+    return C_("Action description", "Toggles the cell");
 
   return parent_action_iface->get_description (action, i - 1);
 }
@@ -54,14 +55,24 @@ gtk_boolean_cell_accessible_action_get_name (AtkAction *action,
   return parent_action_iface->get_description (action, i - 1);
 }
 
+static const gchar *
+gtk_boolean_cell_accessible_action_get_localized_name (AtkAction *action,
+                                                       gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Toggle");
+
+  return parent_action_iface->get_description (action, i - 1);
+}
+
 static gboolean
 gtk_boolean_cell_accessible_do_action (AtkAction *action,
                                        gint       i)
 {
   if (i == 0)
     return parent_action_iface->do_action (action, 2);
-  else
-    return parent_action_iface->do_action (action, i - 1);
+
+  return parent_action_iface->do_action (action, i - 1);
 }
 
 static void
@@ -73,6 +84,7 @@ gtk_boolean_cell_accessible_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_boolean_cell_accessible_get_n_actions;
   iface->get_description = gtk_boolean_cell_accessible_get_description;
   iface->get_name = gtk_boolean_cell_accessible_action_get_name;
+  iface->get_localized_name = gtk_boolean_cell_accessible_action_get_localized_name;
 }
 
 
index f7dece930be4a45b8eed480d57ec03288e763b6f..3ba94d30cf66e1e89dac0e984ad8001cdf888f61 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
 #include "gtkbuttonaccessible.h"
 
 
@@ -327,10 +328,27 @@ static const gchar *
 gtk_button_accessible_action_get_name (AtkAction *action,
                                        gint       i)
 {
-  if (i != 0)
-    return NULL;
+  if (i == 0)
+    return "click";
+  return NULL;
+}
+
+static const gchar *
+gtk_button_accessible_action_get_localized_name (AtkAction *action,
+                                                 gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Click");
+  return NULL;
+}
 
-  return "click";
+static const gchar *
+gtk_button_accessible_action_get_description (AtkAction *action,
+                                              gint       i)
+{
+  if (i == 0)
+    return C_("Action description", "Clicks the button");
+  return NULL;
 }
 
 static void
@@ -340,6 +358,8 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_button_accessible_get_n_actions;
   iface->get_keybinding = gtk_button_accessible_get_keybinding;
   iface->get_name = gtk_button_accessible_action_get_name;
+  iface->get_localized_name = gtk_button_accessible_action_get_localized_name;
+  iface->get_description = gtk_button_accessible_action_get_description;
 }
 
 static const gchar *
index e9b2b8f790c79aec4d7c4cb9113728aa60e68835..e03496b85ae51887f5bfb0a141c79584b937bada 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkcontainercellaccessible.h"
 #include "gtkcellaccessibleprivate.h"
@@ -247,6 +248,23 @@ gtk_cell_accessible_action_get_name (AtkAction *action,
     }
 }
 
+static const gchar *
+gtk_cell_accessible_action_get_localized_name (AtkAction *action,
+                                               gint       index)
+{
+  switch (index)
+    {
+    case 0:
+      return C_("Action name", "Expand or contract");
+    case 1:
+      return C_("Action name", "Edit");
+    case 2:
+      return C_("Action name", "Activate");
+    default:
+      return NULL;
+    }
+}
+
 static const gchar *
 gtk_cell_accessible_action_get_description (AtkAction *action,
                                             gint       index)
@@ -254,11 +272,11 @@ gtk_cell_accessible_action_get_description (AtkAction *action,
   switch (index)
     {
     case 0:
-      return "expands or contracts the row in the tree view containing this cell";
+      return C_("Action description", "Expands or contracts the row in the tree view containing this cell");
     case 1:
-      return "creates a widget in which the contents of the cell can be edited";
+      return C_("Action description", "Creates a widget in which the contents of the cell can be edited");
     case 2:
-      return "activate the cell";
+      return C_("Action description", "Activates the cell");
     default:
       return NULL;
     }
@@ -308,6 +326,7 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_cell_accessible_action_get_n_actions;
   iface->do_action = gtk_cell_accessible_action_do_action;
   iface->get_name = gtk_cell_accessible_action_get_name;
+  iface->get_localized_name = gtk_cell_accessible_action_get_localized_name;
   iface->get_description = gtk_cell_accessible_action_get_description;
   iface->get_keybinding = gtk_cell_accessible_action_get_keybinding;
 }
index 4ca6c7df5dcf952951cc9f04f6342aa009e62c9c..6ad4138e5f9707910db9bc13ba994c9597a5576d 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkcolorswatchaccessibleprivate.h"
 
@@ -61,6 +62,32 @@ gtk_color_swatch_accessible_get_name (AtkAction *action,
     }
 }
 
+static const gchar *
+gtk_color_swatch_accessible_get_localized_name (AtkAction *action,
+                                                gint       i)
+{
+  switch (i)
+    {
+    case 0: return C_("Action name", "Select");
+    case 1: return C_("Action name", "Activate");
+    case 2: return C_("Action name", "Customize");
+    default: return NULL;
+    }
+}
+
+static const gchar *
+gtk_color_swatch_accessible_get_description (AtkAction *action,
+                                             gint       i)
+{
+  switch (i)
+    {
+    case 0: return C_("Action description", "Selects the color");
+    case 1: return C_("Action description", "Activates the color");
+    case 2: return C_("Action description", "Customizes the color");
+    default: return NULL;
+    }
+}
+
 static gboolean
 gtk_color_swatch_accessible_do_action (AtkAction *action,
                                        gint       i)
@@ -99,4 +126,6 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_color_swatch_accessible_get_n_actions;
   iface->get_keybinding = gtk_color_swatch_accessible_get_keybinding;
   iface->get_name = gtk_color_swatch_accessible_get_name;
+  iface->get_localized_name = gtk_color_swatch_accessible_get_localized_name;
+  iface->get_description = gtk_color_swatch_accessible_get_description;
 }
index 8a7008dd3ddfd9b08d53176f948fa76e4d6b54c0..385b26a7315f22d73fc80eeee1e563fb275c041b 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkcomboboxaccessible.h"
 
@@ -299,10 +300,27 @@ static const gchar *
 gtk_combo_box_accessible_action_get_name (AtkAction *action,
                                           gint       i)
 {
-  if (i != 0)
-    return NULL;
+  if (i == 0)
+    return "press";
+  return NULL;
+}
+
+static const gchar *
+gtk_combo_box_accessible_action_get_localized_name (AtkAction *action,
+                                                    gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Press");
+  return NULL;
+}
 
-  return "press";
+static const gchar *
+gtk_combo_box_accessible_action_get_description (AtkAction *action,
+                                                 gint       i)
+{
+  if (i == 0)
+    return C_("Action description", "Presses the combobox");
+  return NULL;
 }
 
 static void
@@ -312,6 +330,8 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_combo_box_accessible_get_n_actions;
   iface->get_keybinding = gtk_combo_box_accessible_get_keybinding;
   iface->get_name = gtk_combo_box_accessible_action_get_name;
+  iface->get_localized_name = gtk_combo_box_accessible_action_get_localized_name;
+  iface->get_description = gtk_combo_box_accessible_action_get_description;
 }
 
 static gboolean
index 07fea6e07918649db695191667a994268abbc4bf..31414c6184bd11820bceebce1d6e2ed92a388d42 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <string.h>
 #include <gtk/gtk.h>
 #include "gtkpango.h"
@@ -1527,10 +1528,27 @@ static const gchar*
 gtk_entry_accessible_action_get_name (AtkAction *action,
                                       gint       i)
 {
-  if (i != 0)
-    return NULL;
+  if (i == 0)
+    return "activate";
+  return NULL;
+}
 
-  return "activate";
+static const gchar*
+gtk_entry_accessible_action_get_localized_name (AtkAction *action,
+                                                gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Activate");
+  return NULL;
+}
+
+static const gchar*
+gtk_entry_accessible_action_get_description (AtkAction *action,
+                                             gint       i)
+{
+  if (i == 0)
+    return C_("Action description", "Activates the entry");
+  return NULL;
 }
 
 static void
@@ -1540,4 +1558,6 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_entry_accessible_get_n_actions;
   iface->get_keybinding = gtk_entry_accessible_get_keybinding;
   iface->get_name = gtk_entry_accessible_action_get_name;
+  iface->get_localized_name = gtk_entry_accessible_action_get_localized_name;
+  iface->get_description = gtk_entry_accessible_action_get_description;
 }
index ae15a22f3706145126c6f036a2c8fbbc1ead20c5..6986e50899c88eaa80a2ba7dc8fdf7d17c5536d3 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkexpanderaccessible.h"
 
@@ -267,10 +268,27 @@ static const gchar *
 gtk_expander_accessible_action_get_name (AtkAction *action,
                                          gint       i)
 {
-  if (i != 0)
-    return NULL;
+  if (i == 0)
+    return "activate";
+  return NULL;
+}
 
-  return "activate";
+static const gchar *
+gtk_expander_accessible_action_get_localized_name (AtkAction *action,
+                                                   gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Activate");
+  return NULL;
+}
+
+static const gchar *
+gtk_expander_accessible_action_get_description (AtkAction *action,
+                                                gint       i)
+{
+  if (i == 0)
+    return C_("Action description", "Activates the expander");
+  return NULL;
 }
 
 static void
@@ -280,4 +298,6 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_expander_accessible_get_n_actions;
   iface->get_keybinding = gtk_expander_accessible_get_keybinding;
   iface->get_name = gtk_expander_accessible_action_get_name;
+  iface->get_localized_name = gtk_expander_accessible_action_get_localized_name;
+  iface->get_description = gtk_expander_accessible_action_get_description;
 }
index 4e14a7158cdfc5e959adceae1b6559a4d43bedb7..15ef15dbed89d66bb8628254bd73fc8983ff3e4a 100644 (file)
@@ -15,6 +15,9 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
 #include <string.h>
 #include <gtk/gtk.h>
 #include "gtkmenuitemaccessible.h"
@@ -420,10 +423,27 @@ static const gchar *
 gtk_menu_item_accessible_action_get_name (AtkAction *action,
                                           gint       i)
 {
-  if (i != 0 || gtk_menu_item_accessible_get_n_actions (action) == 0)
-    return NULL;
+  if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0)
+    return "click";
+  return NULL;
+}
+
+static const gchar *
+gtk_menu_item_accessible_action_get_localized_name (AtkAction *action,
+                                                    gint       i)
+{
+  if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0)
+    return C_("Action name", "Click");
+  return NULL;
+}
 
-  return "click";
+static const gchar *
+gtk_menu_item_accessible_action_get_description (AtkAction *action,
+                                                 gint       i)
+{
+  if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0)
+    return C_("Action description", "Clicks the menuitem");
+  return NULL;
 }
 
 static gboolean
@@ -615,6 +635,8 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->do_action = gtk_menu_item_accessible_do_action;
   iface->get_n_actions = gtk_menu_item_accessible_get_n_actions;
   iface->get_name = gtk_menu_item_accessible_action_get_name;
+  iface->get_localized_name = gtk_menu_item_accessible_action_get_localized_name;
+  iface->get_description = gtk_menu_item_accessible_action_get_description;
   iface->get_keybinding = gtk_menu_item_accessible_get_keybinding;
 }
 
index 7e9253d0188295117f40441956bc0df58159f4b9..fa87e7093982d25a703799b67f9c88484125a3ca 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <config.h>
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkscalebuttonaccessible.h"
 
@@ -133,7 +134,15 @@ static const gchar *
 gtk_scale_button_accessible_get_description (AtkAction *action,
                                              gint       i)
 {
-  return NULL;
+  switch (i)
+    {
+    case 0:
+      return C_("Action description", "Pops up the slider");
+    case 1:
+      return C_("Action description", "Dismisses the slider");
+    default:
+      return NULL;
+    }
 }
 
 static const gchar *
@@ -151,6 +160,21 @@ gtk_scale_button_accessible_action_get_name (AtkAction *action,
     }
 }
 
+static const gchar *
+gtk_scale_button_accessible_action_get_localized_name (AtkAction *action,
+                                                       gint       i)
+{
+  switch (i)
+    {
+    case 0:
+      return C_("Action name", "Popup");
+    case 1:
+      return C_("Action name", "Dismiss");
+    default:
+      return NULL;
+    }
+}
+
 static void
 atk_action_interface_init (AtkActionIface *iface)
 {
@@ -158,6 +182,7 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_n_actions = gtk_scale_button_accessible_get_n_actions;
   iface->get_description = gtk_scale_button_accessible_get_description;
   iface->get_name = gtk_scale_button_accessible_action_get_name;
+  iface->get_localized_name = gtk_scale_button_accessible_action_get_localized_name;
 }
 
 static void
index 3607f8ebf790e8a85b85c7328f84a3c4bd1fef27..bd94d3e91041be281b69fb7b6767dcf6b517b36d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkintl.h"
 #include "gtkswitchaccessible.h"
@@ -87,10 +88,27 @@ static const gchar *
 gtk_switch_action_get_name (AtkAction *action,
                             gint       i)
 {
-  if (i != 0)
-    return NULL;
+  if (i == 0)
+    return "toggle";
+  return NULL;
+}
+
+static const gchar *
+gtk_switch_action_get_localized_name (AtkAction *action,
+                                      gint       i)
+{
+  if (i == 0)
+    return C_("Action name", "Toggle");
+  return NULL;
+}
 
-  return "toggle";
+static const gchar *
+gtk_switch_action_get_description (AtkAction *action,
+                                   gint       i)
+{
+  if (i == 0)
+    return C_("Action description", "Toggles the switch");
+  return NULL;
 }
 
 static gboolean
@@ -122,4 +140,6 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->do_action = gtk_switch_action_do_action;
   iface->get_n_actions = gtk_switch_action_get_n_actions;
   iface->get_name = gtk_switch_action_get_name;
+  iface->get_localized_name = gtk_switch_action_get_localized_name;
+  iface->get_description = gtk_switch_action_get_description;
 }